package com.ruoyi.system.enums;

/**
 * 采购申请单状态枚举
 */
public enum PurchaseRequisitionStatus {
    /**
     * 待提交
     */
    DRAFT("1", "待提交"),

    /**
     * 审批中
     */
    APPROVING("2", "审批中"),

    /**
     * 已批准
     */
    APPROVED("3", "已批准"),

    /**
     * 已拒绝
     */
    REJECTED("4", "已拒绝"),

    /**
     * 已关闭
     */
    CLOSED("5", "已关闭"),

    /**
     * 已撤回
     */
    WITHDRAWN("6", "已撤回");

    private final String code;
    private final String description;

    PurchaseRequisitionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举
     */
    public static PurchaseRequisitionStatus getByCode(String code) {
        for (PurchaseRequisitionStatus value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据description获取枚举
     */
    public static PurchaseRequisitionStatus getByDescription(String description) {
        for (PurchaseRequisitionStatus value : values()) {
            if (value.description.equals(description)) {
                return value;
            }
        }
        return null;
    }
}
